package flex.cc.single.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import flex.cc.single.dao.SingleRecordDao;
import flex.cc.single.dto.entity.SingleRecordEntity;
import flex.cc.single.service.SingleRecordService;

import java.util.Date;

/**
 *
 * @author R
 * @2022年3月31日  19:52:51
 * @desc 单项订单操作记录实现层
 */
@Service("singleRecordService")
public class SingleRecordServiceImpl implements SingleRecordService{

	@Resource
	private SingleRecordDao singleRecordDao;

	/**
	 *
	 * @author R
	 * @2022年3月31日  19:52:51
	 * @desc 信息保存
	 */
	@Override
	public int insertVo(SingleRecordEntity record) {
		return singleRecordDao.insertVo(record);
	}

	/**
	 * @param orderId             订单号：卡券码
	 * @param orderNo             单项服务单号
	 * @param startTime           请求时间
	 * @param endTime             响应时间
	 * @param interfaceName       接口名称
	 * @param status              操作结果
	 * @param remark              描述
	 * @param requestEncryptBody  加密请求奥文
	 * @param requestBody         解密后请求报文
	 * @param responseEncryptBody 加密响应报文
	 * @param responseBodey       解密后响应报文
	 * @return
	 * @description 记录接口请求轨迹
	 * @author wkangle
	 * @time 2022/02/14 0014 15:36
	 * @exception/throws
	 */
	public void saveSingleRecord(String orderId, String orderNo, Date startTime, Date endTime, String interfaceName, String status, String remark,
								  String requestEncryptBody, String requestBody, String responseEncryptBody, String responseBodey) {
		SingleRecordEntity singleRecordEntity = new SingleRecordEntity();
		singleRecordEntity.setOrderId(orderId);
		singleRecordEntity.setOrderNo(orderNo);
		singleRecordEntity.setRequestTime(startTime);
		singleRecordEntity.setResponseTime(endTime);
		singleRecordEntity.setInterfaceName(interfaceName);
		singleRecordEntity.setStatus(status); //操作结果：0-成功、1-失败
		singleRecordEntity.setRemark(remark);
		singleRecordEntity.setRequestEncryptBody(requestEncryptBody);
		singleRecordEntity.setRequestBody(requestBody);
		singleRecordEntity.setResponseEncryptBody(responseEncryptBody);
		singleRecordEntity.setResponseBody(responseBodey);
		singleRecordEntity.setCreateTime(new Date());
		this.insertVo(singleRecordEntity);
	}
}
